package io.dy.mq.producer;

import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @author dmj
 * @date 2024年04月18日 下午4:49
 * topic - 生产者
 */
@Component
@RequiredArgsConstructor
public class TopicProducer {

    private final RabbitTemplate rabbitTemplate;

    public boolean send01(Object msg){
        rabbitTemplate.convertAndSend("dy.topic.exchange", "dy.item", JSONObject.toJSONString(msg));
        return true;
    }

    public boolean send02(Object msg){
        rabbitTemplate.convertAndSend("dy.topic.exchange", "dy.sku", JSONObject.toJSONString(msg));
        return true;
    }

    public boolean send03(Object msg){
        rabbitTemplate.convertAndSend("dy.topic.exchange", "dy.order", JSONObject.toJSONString(msg));
        return true;
    }
}
